<template>
	<view class="wrap">
		<z-paging style="height: 100% !important;" class="wrap" ref="paging" v-model="goodsList" @query="GetQrcodeFileList">
			<cu-custom bgColor="bg-gradual-blue" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">第三方维保数据</block>
			</cu-custom>
			<unifab @dragClick="addFile" creatTop="80" creatLeft="85" image="../../static/jia.png" imageWidth="60upx">
			</unifab>
			<view class="search">
				<u-search placeholder="请输入关键字搜索" v-model="getData.KeyWords" @custom='search()' @search='search()'></u-search>
			</view>
			<sl-filter :themeColor="themeColor" :menuList="menuList" @result="result" @resetMenuList="resetMenuList"></sl-filter>
			<!-- 商品列表开始 -->
			<view v-for="(item, index) in goodsList" class="goods-item-wrap">
				<view class="goods-content-wrap">
					<view class="goods-name">
						<view class="goods-name-title">{{item.FileName}}</view>
						<view class="select-icon"></view>
					</view>
					<view class="goods-stock-wrap">
						<view class="goods-stock">描述</view>
						<view class="goods-stock">{{item.FileDesc}}</view>
					</view>
					<view class="goods-stock-wrap">
						<view class="goods-stock">维保单位</view>
						<view class="goods-stock">{{item.WBCompany}}</view>
					</view>
					<view class="goods-stock-wrap">
						<view class="goods-stock">维保时间</view>
						<view class="goods-stock">{{item.WBDate}}</view>
					</view>
					<view class="goods-stock-wrap" style="border-bottom: 1px solid #F3F4F8;padding-bottom: 10rpx;">
						<view class="goods-stock">上传人</view>
						<view style="display: flex;">
							<view class="goods-stock">{{item.AddUserName}}</view>
						</view>
					</view>
					<view v-if="item.UserType==1" class="goods-price1">小程序人员</view>
					<view v-if="item.UserType==2" class="goods-price2">超级管理员</view>
					<view v-for="(itemj, indexj) in item.FilePathArrys" class="publish-goods-btn1" @click="openDocument(itemj)">
						{{'预览文件'+(indexj+1)}}
					</view>
					<!-- <view class="publish-goods-btn1" @click="downFiles(item.FilePathArrys)">下载文件</view> -->
				</view>
			</view>
			<!-- 商品列表结束 -->
		</z-paging>
	</view>
</template>


<script>
import request from '@/common/request.js';
import unifab from "@/components/beyondGod-drag/beyoundGod-drag.vue";	
export default {
	components: {
			unifab
		},
	data() {
		return {
			getData:{
				KeyWords:'',
				PageIndex:1,
				PageSize:10,
				WBDW:'',
				addUser:'',
				timeList:''
			},
			goodsList:[],
			themeColor: '#0079FE',
			menuList: [
				{
					'title': '填报人',
					'detailTitle': '填报人',
					'isMutiple': false,
					'key': 'user',
					'detailList': [{
							'title': '不限',
							'value': '0'
						}
					]
				
				},
				{
					'title': '维保单位',
					'detailTitle': '维保单位',
					'isMutiple': false,
					'key': 'WBDWList',
					'detailList': [{
							'title': '不限',
							'value': '0'
						}
					]
				},
				{
					'title': '维保时间',
					'detailTitle': '维保时间',
					'isMutiple': false,
					'key': 'timeList',
					'detailList': [{
							'title': '近三月',
							'value': '3m'
						}
					]
				}
			],
		};
	},
	mounted() {
	},
	computed: {
	},
	onLoad() {
		let that=this
		that.GetQrcodeFileList(1,10);
		uni.$on('IsRefresh',function(data){
			console.log('传过来的data：'+data)
			if(data){
				that.GetQrcodeFileList(1,10);
			}
		})
		that.getSearchOptions()
	},
	onUnload() {
		uni.$off('IsRefresh')
	},
	onShow(){
		let that=this
	},
	methods: {
		addFile(){
			uni.showToast({ title: '开发中...', icon: 'none' });
			return
			uni.navigateTo({
				url: '/pages-others/ThirdPartyMaintenance/add'
			})
		},
		openDocument(url){
			console.log(this.$request22.baseUrl1+url)
			uni.downloadFile({
				url: this.$request22.baseUrl1+url,
				success: function(res) {
					var filePath = res.tempFilePath;
					uni.openDocument({
						filePath: filePath,
						success: function(res) {
						}
					});
				}
			})
		},
		result(val) {
			let that=this
			let WBDW=val.WBDWList
			let user=val.user
			let timeList=val.timeList
			//添加人，暂时隐藏
			console.log('user:'+user)
			if(user!=''){
				that.getData.addUser=user
			}else{
				that.getData.addUser=-1
			}
			if(WBDW!=''){
				that.getData.WBDW=WBDW
			}else{
				that.getData.WBDW=''
			}
			if(timeList!=''){
				that.getData.timeList=timeList
			}else{
				that.getData.timeList='3m'
			}
			that.goodsList=[]
			that.GetQrcodeFileList(that.getData.PageIndex,that.getData.PageSize);
			
		},
		GetQrcodeFileList(pageNo, pageSize){
			let that=this
			uni.showLoading({
				title: '加载中...'
			})
			let opts = {
				url: 'WB/GetThirdWBListJson',
				method: 'get'
			};
			that.getData.PageIndex=pageNo;
			that.getData.PageSize=pageSize;
			request.httpTokenRequest(opts,that.getData).then(res => {
				uni.hideLoading();
				if(res.data.code == 1){
					this.$refs.paging.complete(res.data.data);
					uni.hideLoading();
				}
				else{
					uni.showToast({ title: res.data.msg, icon: 'none' });
				}
			});
		},
		// 搜索框
		search(e){
			let that=this
			that.goodsList=[]
			that.getData.PageIndex=1;
			that.getData.PageSize=10;
			that.getData.KeyWords=e
			this.GetQrcodeFileList(1,10);
		},
		getSearchOptions(){
			let that=this
			let opts = {
				url: 'WB/GetThirdWBSearchOptions',
				method: 'get'
			}
			request.httpTokenRequest(opts).then(res => {
				uni.hideLoading();
				if(res.data.code == 1){
					let allPersonList=res.data.data.user
					let WBDWList=res.data.data.WBDWList
					let timeList=res.data.data.timeList
					//用户
					if(allPersonList.length>0){
						let datalist=[]
						let entity={
							title:'不限',
							value:''
						}
						datalist.push(entity)
						for(let i=0;i<allPersonList.length;i++){
							let entity={
								title:allPersonList[i].RealName,
								value:allPersonList[i].Id
							}
							datalist.push(entity)
						}
						that.menuList[0].detailList=datalist
					}
					
					
					//维保单位
					if(WBDWList.length>0){
						let datalist=[]
						let entity={
							title:'不限',
							value:''
						}
						datalist.push(entity)
						for(let i=0;i<WBDWList.length;i++){
							let entity={
								title:WBDWList[i].data,
								value:WBDWList[i].data
							}
							datalist.push(entity)
						}
						console.log('WBDWList:'+datalist)
						that.menuList[1].detailList=datalist
					}
					//时间
					if(timeList.length>0){
						let datalist=[]
						for(let i=0;i<timeList.length;i++){
							let entity={
								title:timeList[i].Name,
								value:timeList[i].Time
							}
							datalist.push(entity)
						}
						console.log('timeList:'+datalist)
						that.menuList[2].detailList=datalist
					}
				}
				else{
					uni.showToast({ title: res.data.msg, icon: 'none' });
				}
			});
			
		},
	}
};
</script>


<style lang="scss" scoped>
	.search{
		width: 100%;
		height: 100rpx;
		padding: 20rpx 2% 0 2%;
		background-color: #fff;
		// display: flex;
		// align-items: center;
	}
	.cu-tag.badge{
		top:-10rpx !important;
		right:30rpx !important;
	}
	.goods-item-wrap-now{
		//border:2px solid #00B52A;
	}
	.goods-item-wrap {
		border-radius: 8rpx;
		background: #FFFFFF;
		display: flex;
		padding: 24rpx;
		margin: 12rpx;
		//width:100%;
		.goods-content-wrap{
			width: 100%;
		}
		.goods-name {
			width: 100%;
			font-size: 32rpx;
			font-weight: bold;
			display: flex;
			position: relative;
			border-bottom: 1px solid #F3F4F8;
			padding-bottom: 20rpx;
		}
		.goods-name-title{
			display: block;
			float: left;
		}
		.goods-name-type{
			display: block;
			float:right;
			color: #3B69FD;
			margin-right: 20rpx;
		}
		.goods-stock-wrap {
			display: flex;
			color: #969696;
			font-size: 24rpx;
			margin-top: 20rpx;
			justify-content: space-between;
		}
		
		.goods-stock {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #636571;
			line-height: 32rpx;
		}
		.goods-stock-isok{
			margin-right: 10rpx;
			font-size: 38rpx;
			color: #00B52A;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-middle{
			margin-right: 10rpx;
			font-size: 38rpx;
			color: #636571;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-notok{
			margin-right: 24rpx;
			font-size: 38rpx;
			color: #F53F3E;
			line-height: 32rpx;
			font-weight: 700;
		}
		.goods-stock-time {
			margin-right: 24rpx;
			font-size: 28rpx;
			color: #e7612e;
			padding-bottom: 20rpx;
		}
		.goods-shangxiaxian {
			font-size:24rpx;
			color: #3F71C4;
			margin-top: 14rpx;
		}
		
		.goods-price1 {
			font-size:26rpx;
			color: #3B69FD;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #D0D9F7;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-price2 {
			font-size:26rpx;
			color: #15C9CA;
			margin-top: 20rpx;
			font-weight:500;
			width: 160rpx;
			display: block;
			float:left;
			background-color: #C8ECEC;
			border-radius: 4rpx;
			text-align: center;
			height: 54rpx;
			line-height: 54rpx;
		}
		.goods-option-item {
			padding: 8rpx 16rpx;
			border-radius: 36rpx;
			font-size: 24rpx;
			margin-top: 24rpx;
		}
	}
	
.wrap {
	display: flex;
	flex-direction: column;
	height: calc(100vh - var(--window-top));
	width: 100%;
}
.swiper-box {
	flex: 1;
}
.swiper-item {
	height: 100%;
}

	.goods-option-item {
		padding: 8rpx 16rpx;
		border-radius: 36rpx;
		font-size: 24rpx;
		margin-top: 24rpx;
	}

	.goods-option-item:not(:last-child) {
		margin-right: 24rpx;
	}

	.goods-option-item-action {
		background: #f1f0fe;
		color: #6991ce;
	}

	.goods-item-wrap {
		margin-top: 24rpx;
	}

	.goods-header-wrap {
		display: flex;
		align-items: center;
		padding: 24rpx;
		background: #FFFFFF;
		margin-bottom: 10rpx;
	}
	.goods-header-item{
		width:49%;
		text-align: center;
	}
	.goods-header-item-active{
		font-size: 30rpx;
		font-color: #333333;
		font-weight: bold;
		position: relative;
	}
	.goods-header-item-active::after{
		position: absolute;
		left: 50%;
		right: 0;
		background: #4372fe;
		height: 8rpx;
		content: "";
		bottom: -12rpx;
		width: 60rpx;
		margin-left: -30rpx;
		border-radius: 200rpx;
	}
	.goods-header-item-action {
		// font-size: 32rpx;
		// font-color: #333333;
		// font-weight: bold;
		position: relative;
	}

	.goods-header-item-action::after {
		// position: absolute;
		// left: 0;
		// right: 0;
		// background: #4372fe;
		// height: 8rpx;
		// content: "";
		// bottom: -12rpx;
	}
	.extraPosition{
		position: absolute;
		right: -5rpx;
		top: -10rpx;
		font-size: 20rpx;
		padding: 0rpx 10rpx;
		height: 28rpx;
		color: #ffffff;
		background-color: #dd514c;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}
	
	.publish-goods-btn {
		width:160rpx;
		background: #e7612e;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}
	
	.publish-goods-btn1 {
		width:160rpx;
		background: #3B69FD;;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
		font-size:24rpx;
	}
	
	.publish-goods-btn2 {
		width:160rpx;
		background: #00B52A;;
		color: #FFFFFF;
		height: 54rpx;
		line-height: 54rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 82rpx;
		float:right;
		margin-right: 20rpx;
		margin-top: 20rpx;
	}
	
	
	.select-icon{
		border-bottom: 3rpx solid #999;
		border-right: 3rpx solid #999;
		width: 16rpx;
		height: 16rpx;
		transform: rotate(-45deg);
		position: absolute;
		right: 20rpx;
		top: 14rpx;
	}
</style>

